package de.fhb.itunes.controller.web;


import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import de.fhb.itunes.manager.Config;
import de.fhb.itunes.manager.filewatcher.OrdnerUebweachung;
import de.fhb.itunes.manager.mail.Mail;
import de.fhb.itunes.manager.mail.Template.HTML_Templates;
import de.fhb.itunes.manager.mail.Template.Template;
import de.fhb.itunes.manager.mail.Template.TemplateBuilder;

/**
 * Servlet implementation class newMediaFileServlet
 */
@WebServlet("/newMediaFileServlet")
public class newMediaFileServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public newMediaFileServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		OrdnerUebweachung ordner = new OrdnerUebweachung();
		ordner.checkDir();
		TemplateBuilder tb = new TemplateBuilder(ordner.getFilmeNames());
		
		Template standard = new Template(HTML_Templates.textonly,"Es gibt gute Nachrichten!!! Es wurden neue Titel zu Ihrer Mediathek hinzugefügt","","");
		
//		Template one = new Template(HTML_Templates.fullwidthImage,"Das ist ein Text","Das ist der Titel","http://www.google.de/intl/de_ALL/images/logos/images_logo_lg.gif");
//		Template two = new Template(HTML_Templates.textWithLeftAlignedImage,"Das ist ein Text","Das ist der Titel","http://www.google.de/intl/de_ALL/images/logos/images_logo_lg.gif");
		
		Mail mail = new Mail();
		mail.addTemplate(standard);
		for (Template template : tb.getTemplates()) {
			mail.addTemplate(template);
		}
		mail.send();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
